package com.google.android.exoplayer2.ui;

import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.support.v4.app.NotificationCompat;

/* loaded from: classes.dex */
public final class DownloadNotificationUtil {
    private static final int NULL_STRING_ID = 0;

    private DownloadNotificationUtil() {
    }

    /* JADX WARN: Removed duplicated region for block: B:29:0x0060  */
    /* JADX WARN: Removed duplicated region for block: B:34:0x006a  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public static android.app.Notification buildProgressNotification(android.content.Context r17, int r18, java.lang.String r19, android.app.PendingIntent r20, java.lang.String r21, com.google.android.exoplayer2.offline.DownloadManager.TaskState[] r22) {
        /*
            r0 = r22
            int r1 = r0.length
            r2 = 1
            r3 = 0
            r4 = 0
            r4 = 0
            r5 = 0
            r6 = 0
            r7 = 0
            r8 = 0
            r9 = 1
            r10 = 0
        Ld:
            if (r4 >= r1) goto L42
            r11 = r0[r4]
            int r12 = r11.state
            if (r12 == r2) goto L1b
            int r12 = r11.state
            r13 = 2
            if (r12 == r13) goto L1b
            goto L3f
        L1b:
            com.google.android.exoplayer2.offline.DownloadAction r12 = r11.action
            boolean r12 = r12.isRemoveAction
            if (r12 == 0) goto L23
            r6 = 1
            goto L3f
        L23:
            float r5 = r11.downloadPercentage
            r12 = -1082130432(0xffffffffbf800000, float:-1.0)
            int r5 = (r5 > r12 ? 1 : (r5 == r12 ? 0 : -1))
            if (r5 == 0) goto L2f
            float r5 = r11.downloadPercentage
            float r7 = r7 + r5
            r9 = 0
        L2f:
            long r11 = r11.downloadedBytes
            r13 = 0
            int r5 = (r11 > r13 ? 1 : (r11 == r13 ? 0 : -1))
            if (r5 <= 0) goto L39
            r5 = 1
            goto L3a
        L39:
            r5 = 0
        L3a:
            r5 = r5 | r10
            int r8 = r8 + 1
            r10 = r5
            r5 = 1
        L3f:
            int r4 = r4 + 1
            goto Ld
        L42:
            if (r5 == 0) goto L49
            int r0 = com.google.android.exoplayer2.ui.R.string.exo_download_downloading
        L46:
            r16 = r0
            goto L50
        L49:
            if (r6 == 0) goto L4e
            int r0 = com.google.android.exoplayer2.ui.R.string.exo_download_removing
            goto L46
        L4e:
            r16 = 0
        L50:
            r11 = r17
            r12 = r18
            r13 = r19
            r14 = r20
            r15 = r21
            android.support.v4.app.NotificationCompat$Builder r0 = newNotificationBuilder(r11, r12, r13, r14, r15, r16)
            if (r5 == 0) goto L6a
            float r1 = (float) r8
            float r7 = r7 / r1
            int r1 = (int) r7
            if (r9 == 0) goto L68
            if (r10 == 0) goto L68
            goto L6b
        L68:
            r4 = 0
            goto L6c
        L6a:
            r1 = 0
        L6b:
            r4 = 1
        L6c:
            r5 = 100
            r0.setProgress(r5, r1, r4)
            r0.setOngoing(r2)
            r0.setShowWhen(r3)
            android.app.Notification r0 = r0.build()
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.exoplayer2.ui.DownloadNotificationUtil.buildProgressNotification(android.content.Context, int, java.lang.String, android.app.PendingIntent, java.lang.String, com.google.android.exoplayer2.offline.DownloadManager$TaskState[]):android.app.Notification");
    }

    public static Notification buildDownloadCompletedNotification(Context context, int i, String str, PendingIntent pendingIntent, String str2) {
        return newNotificationBuilder(context, i, str, pendingIntent, str2, R.string.exo_download_completed).build();
    }

    public static Notification buildDownloadFailedNotification(Context context, int i, String str, PendingIntent pendingIntent, String str2) {
        return newNotificationBuilder(context, i, str, pendingIntent, str2, R.string.exo_download_failed).build();
    }

    private static NotificationCompat.Builder newNotificationBuilder(Context context, int i, String str, PendingIntent pendingIntent, String str2, int i2) {
        NotificationCompat.Builder smallIcon = new NotificationCompat.Builder(context, str).setSmallIcon(i);
        if (i2 != 0) {
            smallIcon.setContentTitle(context.getResources().getString(i2));
        }
        if (pendingIntent != null) {
            smallIcon.setContentIntent(pendingIntent);
        }
        if (str2 != null) {
            smallIcon.setStyle(new NotificationCompat.BigTextStyle().bigText(str2));
        }
        return smallIcon;
    }
}
